<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <!--Inicia la composicion de la pagina en la plantilla-->
    <ui:composition template="/resource/template/plantilla.xhtml">

        <!--Segmento que define el contenido del header-->
        <ui:define name="head">
            <h:head>
                <f:loadBundle basename="person.knowledge.label_#{logged.loggedIdiom}" var="label" />
                <f:loadBundle basename="person.knowledge.message_#{logged.loggedIdiom}" var="message" />
                <f:loadBundle basename="person.knowledge.help_#{logged.loggedIdiom}" var="help" />
                <script>
                    function verificar(dato)
                    {
                        var agree = confirm(dato);
                        if (agree)
                            return true;
                        else
                            return false;
                    }
                </script>
            </h:head>
        </ui:define>

        <!--Segmento que define el contenido de la pagina-->
        <ui:define name="content">
            <h:body>
                <h:outputText value="#{message.m0}" class="label" rendered="#{!access.visit}"/>
                <h:form rendered="#{access.visit}">  
                    <p:growl id="messages" showDetail="true"/>  

                    <!--Selecioanar conocimiento  -->
                    <div class="field">
                        <h:outputText value="#{label.field1}" class="label"/>
                        <h:selectOneMenu value="#{person_knowledge.idl_tipo}">  
                            <f:selectItem itemLabel="" itemDisabled="true"/>
                            <f:selectItem itemLabel="#{label.tipo1000}" itemValue="1000"/> 
                            <f:selectItem itemLabel="#{label.tipo1001}" itemValue="1001"/> 
                            <f:selectItem itemLabel="#{label.tipo1002}" itemValue="1002"/> 
                            <f:selectItem itemLabel="#{label.tipo1003}" itemValue="1003"/> 
                            <f:selectItem itemLabel="#{label.tipo1004}" itemValue="1004"/> 
                            <f:selectItem itemLabel="#{label.tipo1005}" itemValue="1005"/> 
                            <f:selectItem itemLabel="#{label.tipo1006}" itemValue="1006"/> 
                            <f:selectItem itemLabel="#{label.tipo1007}" itemValue="1007"/>
                            <f:selectItem itemLabel="#{label.tipo1008}" itemValue="1008"/> 
                            <f:selectItem itemLabel="#{label.tipo1009}" itemValue="1009"/> 
                            <f:selectItem itemLabel="#{label.tipo1010}" itemValue="1010"/> 
                            <f:selectItem itemLabel="#{label.tipo1011}" itemValue="1011"/>
                        </h:selectOneMenu>
                        <h:outputText class="required" value="*"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field3}" class="label"/>
                        <h:selectOneMenu value="#{person_knowledge.idl_nivel}">  
                            <f:selectItem itemLabel="" itemDisabled="true"/>
                            <f:selectItem itemLabel="#{label.Nivel1}" itemValue="1"/> 
                            <f:selectItem itemLabel="#{label.Nivel2}" itemValue="2"/> 
                            <f:selectItem itemLabel="#{label.Nivel3}" itemValue="3"/> 
                            <f:selectItem itemLabel="#{label.Nivel4}" itemValue="4"/>
                        </h:selectOneMenu>
                        <h:outputText class="required" value="*"/>
                    </div>

                    <!--Introducir  conocimiento  -->
                    <div class="field">
                        <h:outputText value="#{label.field2}" class="label"/>
                        <h:inputTextarea id="detalle" value="#{person_knowledge.detalle}" class="textArea"  required="#{param['required']=='true'}" requiredMessage="#{message.m21}"/>
                        <p:watermark for="detalle" value="#{label.field1}"/>
                    </div>
                    <!--INSERTAR -->
                    <h:commandButton value="#{label.button1}" class="button" actionListener="#{person_knowledge.insert}" rendered="#{access.add}" onclick="return verificar('#{message.m7}')">
                        <f:param name="required" value="true"/>
                    </h:commandButton>
                    <!--ACTUALIZAR -->
                    <h:commandButton value="#{label.button2}" class="button" actionListener="#{person_knowledge.update}" rendered="#{access.update}" onclick="return verificar('#{message.m8}')">
                        <f:param name="required" value="true"/>
                    </h:commandButton>
                    <!--ELIMINAR -->
                    <h:commandButton value="#{label.button3}" class="button" actionListener="#{person_knowledge.delete}" rendered="#{access.delete}" onclick="return verificar('#{message.m9}')"/>
                    <!--LIMPIAR -->
                    <h:commandButton value="#{label.button4}" class="button" actionListener="#{person_knowledge.clear}"/>
                </h:form>
                <h:form>
                    <c:set var="list" value="#{person_knowledgeFind.listByLoggedId}"/>
                    <h:panelGroup layout="block" class="tableWrapper" rendered="#{not empty list}">
                        <h:dataTable var="p" value="#{list}" class="dataTable">
                            <h:column>
                                <h:commandLink styleClass="editButton" actionListener="#{person_knowledge.selectedRecord(p.id)}"/>
                            </h:column>
                            <h:column >
                                <f:facet name="header">#{label.field1}</f:facet>
                                <c:set var="tipo" value="tipo#{p.idl_tipo}" />
                                <h:outputText value="#{label[tipo]}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">#{label.field3}</f:facet>
                                <c:set var="nivel" value="Nivel#{p.idl_nivel}" />
                                <h:outputText value="#{label[nivel]}"/>
                            </h:column>
                            <h:column >
                                <f:facet name="header">#{label.field2}</f:facet> 
                                <h:outputText value="#{p.detalle}"/>
                            </h:column>
                        </h:dataTable>
                    </h:panelGroup>
                </h:form>

            </h:body>
        </ui:define>

        <!--Segemento donde se define un texto de ayuda para que el usuario pueda utilizar el formulario del contenido-->
        <ui:define name="slideHelper">
            <h3>#{help.title1} </h3>
            #{help.detail1a}
            <p>
                #{help.title2}
                <ul>
                    <li>#{help.detail2a}</li>
                </ul> 
                #{help.title3}
                <ul>
                    <li>#{help.detail3a}</li>
                    <li>#{help.detail3b}</li>
                </ul>
            </p>
        </ui:define>
    </ui:composition>
</html>

